;*****************************************************************************************************
;+
; NAME:
;
;      IGL_SetCursorShape
;
; PURPOSE:
;
;      This routine is used to make the cursor to a given shape in
;      IDL direct graphics windows (which includes IGL windows). In
;      principle, it should not be called directly by the user.
;
;
; CALLING SEQUENCE:
;
;      IGL_SetCursorShape, shape
;
; ARGUMENTS:
;
;      SHAPE:         The desired shape of the cursor.
;                     Available shapes are :
;
;                      ['CROSSHAIR','CROSSARROWS','ARROW','HAND','VRULE']
;
;                     The default is 'CROSSHAIR'.
;                 
; KEYWORD PARAMETERS:
;
;      None.
;
; PACKAGE:
;
;    Interactive Graphics Library (IGL)
;
; AUTHORS:
;
;        RAPHAEL SADOUN
;        Graduate Student
;        Institut d'Astrophysique de Paris
;        98 bis boulevard Arago
;        75014 PARIS FRANCE
;        E-mail: raphael.sadoun@gmail.com
;
;
; MODIFICATION HISTORY:
;
;     Written by: Raphael Sadoun, 24 April 2012
;-
;*****************************************************************************************************
PRO IGL_SetCursorShape, shape

  COMPILE_OPT idl2, HIDDEN  
  ON_ERROR, 2

  ;; Default shape value 
  IF (n_elements(shape) EQ 0) THEN shape = 'CROSSHAIR'

  ;; Available shapes for the cursor
  availableShapes = ['CROSSHAIR','CROSSARROWS','ARROW','HAND','VRULE']

  ;; Make sure we have a valid shape name
  shapeIndex = where(strupcase(shape) EQ availableShapes,validShape)
  IF (validShape EQ 0) THEN return

  ;; Change cursor shape for direct graphics
  CASE strupcase(shape) OF
     'CROSSHAIR': device, /cursor_crosshair
     'ARROW': device, /cursor_original
     'CROSSARROWS':BEGIN
        image = [ $
                0, $
                32768, $
                49153, $
                57347, $
                32768, $
                34824, $
                35864, $
                65087, $
                35864, $
                34824, $
                32768, $
                57347, $
                49153, $
                32768, $
                0, $
                0 $
                ]
        mask = [ $
               32768, $
               49153, $
               57347, $
               61447, $
               63503, $
               56349, $
               65087, $
               65407, $
               65087, $
               56349, $
               63503, $
               61447, $
               57347, $
               49153, $
               32768, $
               0 $
               ]
        hotspot = [7,8]
        device, cursor_image=image, cursor_mask=mask, cursor_xy=hotspot
     END
     'HAND': BEGIN
        image = [ $
                0, $
                1, $
                49159, $
                40970, $
                40970, $
                43018, $
                46106, $
                46122, $
                46122, $
                13344, $
                1056, $
                2080, $
                4112, $
                57359, $
                0, $
                0 $
                ]
        mask = [ $
               1, $
               49159, $
               57359, $
               61471, $
               63519, $
               64543, $
               65087, $
               65151, $
               65151, $
               65151, $
               65151, $
               64639, $
               63551, $
               61471, $
               57359, $
               0 $
               ]
        hotspot = [8,13]
        device, cursor_image=image, cursor_mask=mask, cursor_xy=hotspot
     END
     'VRULE': BEGIN
        IF !D.Name EQ 'WIN' THEN BEGIN
           Device, Cursor_Standard=32513L 
        ENDIF ELSE BEGIN
           Device, CURSOR_STANDARD=152
        ENDELSE
     END
     ELSE:
  ENDCASE

END
